home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 March: Reference Library / Dev.CD Mar 96 RL / Dev.CD Mar 96 RL.toast / Technical Documentation / develop / develop Issue 25 / develop Issue 25 code / QD3D to QTVR / ArticleCode / Source / traps.c < prev    next >
Encoding:
Text File  |  1995-10-08  |  996 b   |  49 lines  |  [TEXT/MPCC]

  1. // Simple framework for Macintosh sample code
  2. //
  3. // Nick Thompson, DEVSUPPORT
  4. //
  5. // This file contains the trap detection related code code for the framework.
  6. // 
  7. // 9/16/94    nick    first cut
  8.  
  9. #include <Types.h>
  10. #include <Traps.h>
  11. #include <OSUtils.h>
  12. #include <GestaltEqu.h>
  13.  
  14. short myNumToolboxTraps(void);
  15. TrapType myGetTrapType(short theTrap);
  16. Boolean    myTrapAvailable(short theTrap);
  17.  
  18. short myNumToolboxTraps(void)
  19. {
  20.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  21.         return 0x0200;
  22.     else
  23.         return 0x0400;
  24. }
  25.  
  26. TrapType myGetTrapType(short theTrap)
  27. {
  28.     if ((theTrap & 0x0800) > 0)
  29.         return ToolTrap;
  30.     else
  31.         return OSTrap;
  32. }
  33.  
  34. Boolean    myTrapAvailable(short theTrap)
  35. {
  36.     TrapType tType;
  37.     Boolean isAvail;
  38.     
  39.     tType = myGetTrapType(theTrap);
  40.     if (tType == ToolTrap)
  41.         {
  42.             theTrap &= 0x07FF;
  43.             if (theTrap >= myNumToolboxTraps())
  44.                 theTrap = _Unimplemented;
  45.         }
  46.     
  47.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  48.     return isAvail;
  49. }